import {
  Controller,
  Get,
  Post,
  Body,
  Put,
  Param,
  Delete,
  NotFoundException,
} from '@nestjs/common'
import { UserService } from './user.service'
import { CreateUserDto } from './dto/create-user.dto'
import { UpdateUserDto } from './dto/update-user.dto'
// import { AuthGuard } from '@nestjs/passport'
// import { AuthGuard as AdminGuard } from 'src/common/guard/admin.guard'
import { SkipDecorator } from 'src/common/decorator/skip-decorator.decorator'

@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  @Post()
  create(
    @Body() createUserDto: CreateUserDto,
    // @Query('page') page: string,
    // @Param('id') id: string,
    // @Body() body: any,
    // @Headers('Authorization') auth: string,
  ) {
    // console.log(page, 'page')
    // console.log(id, 'id')
    // console.log(body, 'body')
    // console.log(auth, 'auth')
    return this.userService.create(createUserDto)
  }

  @Get()
  @SkipDecorator()

  // @UseGuards(AuthGuard('jwt'))
  findAll() {
    return this.userService.findAll()
  }

  @Get(':id')
  // @UseGuards(AuthGuard('jwt'), AdminGuard)
  async findOne(@Param('id') id: string) {
    const user = await this.userService.findOne(+id)
    if (!user) {
      throw new NotFoundException('User not found')
    }
    return user
  }

  @Put(':id')
  update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) {
    return this.userService.update(+id, updateUserDto)
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.userService.remove(+id)
  }
}
